home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 9426 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.8 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.unix.programmer,comp.lang.c
  4. Subject: Re: Runtime ANSI C checking tool?
  5. Date: Sun, 10 Mar 96 16:19:16 GMT
  6. Organization: none
  7. Message-ID: <826474756snz@genesis.demon.co.uk>
  8. References: <DnI89B.EnH@pgh.nauticom.net> <p5ag239ede.fsf@lemming.wellfleet.com> <TANMOY.96Mar7180501@qcd.lanl.gov>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <TANMOY.96Mar7180501@qcd.lanl.gov>
  15.            tanmoy@qcd.lanl.gov "Tanmoy Bhattacharya" writes:
  16.  
  17. >In article <826219697snz@genesis.demon.co.uk>
  18. >Lawrence Kirby <fred@genesis.demon.co.uk> writes:
  19. >
  20. >LK: >Well, a well-written ANSI C compiler should handle all language
  21. >LK: >violations, and a well-written ANSI C system library should catch all
  22. >LK: >runtime violations (passing NULL to strcpy() or something, for
  23. >LK: >example).
  24. >LK: 
  25. >LK: Not possible in general (at least for the compiler or the standard library)
  26. >LK: e.g.
  27. >LK: 
  28. >LK: int foo(int *p, int *q)
  29. >LK: {
  30. >LK:     return ++*p + ++*q;
  31. >LK: }
  32. >LK: 
  33. >LK: This results in undefined behaviour if the same value is passed for p and
  34. >LK: q.
  35. >
  36. >Well, it is possible for the compiler to put in a runtime check :-)
  37.  
  38. True, i meant it isn't possible for this to be detected at compile time
  39. or by the standard library. If the compiler did put in runtime checking it
  40. would have to deal with code such as:
  41.  
  42.      ++*a + ++*b + ++*c + ++*d + ++*e ........
  43.  
  44. which gets more interesting. Then you might consider pointer to different
  45. types and so on.
  46.  
  47. -- 
  48. -----------------------------------------
  49. Lawrence Kirby | fred@genesis.demon.co.uk
  50. Wilts, England | 70734.126@compuserve.com
  51. -----------------------------------------
  52.